<template>
  <div class="jobdetail-box ct">
    <el-breadcrumb class="head-nav" :separator-icon="ArrowRight">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/job' }">工作动态</el-breadcrumb-item>
      <el-breadcrumb-item :to="{path: nav1}">{{ tite1 }}</el-breadcrumb-item>
      <el-breadcrumb-item>{{ tite2 }}</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="detail-content">
      <div class="content-l">
        <!-- <div class="content-head">
          <div class="h3">{{ artice[title3] }}</div>
          <div class="sp tac">{{ artice.createdTime }} 浏览数：{{ artice.pageView }}次</div>
        </div> -->
        <div class="c-t">{{ artice[title3] }}</div>
        <div class="c-t-img">
          <div class="img-b">
            <img class="1p" src="./1.png" alt="">
            <div class="img-text">
              <div>河南农业大学</div>
              <div>明德自强 求是力行</div>
            </div>
          </div>
          <div class="t-title">
            <div class="t-t">工作日志</div>
          </div>
          <div class="img-b">
            <img class="2p" src="./2.png" alt="">
            <div class="img-text">
              <div>{{ artice.courtyardName }}</div>
              <div>扎根农村服务三农</div>
            </div>
          </div>
        </div>
        <div class="kk">
          <div>日期：{{ artice.logDate }} {{ artice.week }}</div>
          <div class="k-r">编辑人：{{ artice.editor }}</div>
        </div>

        <div class="details">
          <div class="details-d" v-if="artice.videoUrl">
            <video width="100%" height="500" muted controls autoplay="autoplay" preload>
              <source :src="artice.videoUrl" type="video/mp4">
              您的浏览器不支持 video 标签。
          </video>
          </div>
          <template v-else>
            <div class="h33">{{ artice[title3] }}</div>
            <div class="details-d" v-html="artice[contentKey]"></div>
          </template>
 
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ArrowRight } from '@element-plus/icons-vue'
import { getWorkStateById, getBulletinById, getPoliciesRegulationsById, getScientificResearchById, getCourtyardLogById,
  getInformationById
 } from '@/api/home'
import { useRouter } from 'vue-router';
import { computed, ref, onMounted } from 'vue'

const dataMap = {
  job: {
    func: getWorkStateById,
    title: '最新动态',
    detail: '动态详情',
    nav1: '/job/jobmore',
    key: 'bulletinId',
    contentKey: 'workContent',
    pageTitle: 'workTitle'
  },
  bulletin: {
    func: getBulletinById,
    title: '通知公告',
    detail: '公告详情',
    nav1: '/job/noticemore',
    key: 'bulletinId',
    contentKey: 'bulletinContent',
    pageTitle: 'bulletinTitle'
  },
  policy: {
    func: getPoliciesRegulationsById,
    title: '政策法规',
    detail: '法规详情',
    key: 'policiesId',
    nav1: '/job/jobpolicymore',
    contentKey: 'policiesContent',
    pageTitle: 'policiesTitle'
  },
  science: {
    func: getScientificResearchById,
    title: '科学研究',
    detail: '研究详情',
    key: 'researchId',
    nav1: '/job/jobsciencemore',
    contentKey: 'researchContent',
    pageTitle: 'researchTitle'

  },
  yardlog: {
    func: getCourtyardLogById,
    title: '站院日志',
    detail: '日志详情',
    key: 'logId',
    contentKey: 'logContent',
    pageTitle: 'logTitle',
    nav1: '/job/joblogmore',
  },
  information: {
    func: getInformationById,
    title: '科普资料',
    detail: '资料详情',
    key: 'informationId',
    contentKey: 'content',
    pageTitle: 'title'
    
  }
}

const router = useRouter();
console.log('00router', router)
const id = computed(() => router?.currentRoute?.value?.params.id)
const type = computed(() => router?.currentRoute?.value?.query.type);

const tite1 = computed(() => {
  return dataMap[type.value]?.title
})
const tite2 = computed(() => {
  return dataMap[type.value]?.detail
})
const nav1 = computed(() => {
  return dataMap[type.value]?.nav1
})
const contentKey = computed(() => {
  return dataMap[type.value]?.contentKey
})
const title3 = computed(() => {
  return dataMap[type.value]?.pageTitle
})
const artice = ref({});
onMounted(async () => {
  const func = dataMap[type.value]?.func;
  const ret = await func({ [dataMap[type.value]?.key]: id.value })
  console.log('00ret', ret)
  artice.value = ret?.data
})

</script>
<style lang="scss" scoped>
.jobdetail-box {
  padding: 0 10%;
  flex: 1;
  width: 100%;
  background:  url('../../assets/xiaoyuan/4.jpeg') no-repeat center center / 100% 100%;
  color: #666;

  .head-nav {
    height: 125px;
    display: flex;
    align-items: center;
    font-size: 24px;
  }

  .c-t-img {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 40px 40px 20px;
    .img-b {
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    .img-text {
      text-align: center;
      padding-top: 20px;
    }
    img {
      width: 200px;
    }
    .t-title {
      .t-t {
        font-size: 100px;
        font-weight: 900;
        color: #068043;
      }
      .t-b{
        text-align: center;
        padding-top: 60px;
        font-weight: 700;
        font-size: 24px;
        color: #333;
      }
    }

  }

  .kk {
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid #068043;
      margin: 20px 40px 10px 40px;
      color: #777;
      .k-r {
        padding-left: 100px;
      }
    }

  .detail-content {
    // display: flex;
    min-height: 1000px;
    font-family: "SimSun", "宋体", "PingFang SC", "Microsoft YaHei", sans-serif;

    .c-t {
      padding: 20px;
      background-color: #f5f5f5;
    }

    .content-l {
      background-color: #fff;
      color: #666;
      font-size: 20px;
      min-height: 100%;
      position: relative;
      padding-bottom: 40px;
      width: 100%;
      .b-nav {
        color: #666;
        position: absolute;
        height: 112px;
        width: 100%;
        bottom: 0;
        left: 0;
        display: flex;
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        padding-left: 30px;
        padding-right: 30px;

        .o {
          width: 100%;
          height: 30px;
          cursor: pointer;
        }
      }

      .content-head {
        padding: 0 30px 15px;
      }

      .h3 {
        font-weight: bold;
        font-size: 32px;
        color: #000;
        display: flex;
        justify-content: center;

      }

      .sp {
        line-height: 32px;
        //text-indent: 4%;
      }

      .details {
        padding: 0 20px 40px;
        height: 100%;
      background-color: #f2f8f5;
      margin: 0 40px 0 40px;
        border: 1px solid #c4e8d7;
        color: #333;
        .h33 {
            height: 180px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 50px;
            color: #333;
            font-weight: 700;
          }
      }

      :deep(.details-d) {
        p {
          line-height: 32px;
          //text-indent: 4%;
          img {
          display: block;
          }
        }
        img {
          width: 100%;
          height: 500px;
          object-fit: contain;
          //text-indent: 0%;
          margin: 20px 0;
        }
      }
    }
  }
}
</style>